package functions;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class Functions {
	public static Collection subSet(int start,int end, Collection c){
		Collection tmp = new ArrayList();
		Object tab[] = c.toArray();
		for(int i = start; i < end; i++){
			tmp.add(tab[i]);
		}
		return tmp;
	}
	
	public static Collection sortAsc(Collection c){
		if(c instanceof List){
			List tmp = (List) c;
			Collections.sort(tmp);
			return tmp;
		} else {
			System.err.println("Kolekcja nie implementuje interfejsu List");			
			return null;
		}
	}
	
	public static Collection sortDesc(Collection c){
		if(c instanceof List){
			List tmp = (List) c;
			Collections.sort(tmp);
			Collections.reverse(tmp);
			return tmp;
		} else {
			System.err.println("Kolekcja nie implementuje interfejsu List");			
			return null;
		}
	}
}
